<#assign menuId=7>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>工厂详情-${Application.systemName!}</title>
        <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
        <!-- bootstrap 3.0.2 -->
        <link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
        <!-- font Awesome -->
        <link href="../css/font-awesome.min.css" rel="stylesheet" type="text/css" />
        <!-- Ionicons -->
        <link href="../css/ionicons.min.css" rel="stylesheet" type="text/css" />
        <!-- Theme style -->
        <link href="../css/AdminLTE.css" rel="stylesheet" type="text/css" />
        <link href="../css/myself.css" rel="stylesheet" type="text/css" />
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}
			
			ul li {
				list-style: none;
			}
			
			.pull {
				margin-bottom: 10px;
			}
			
			.pull-left {
				border-left: 6px solid #3882FF;
				padding: 0 5px;
				font-size: 14px;
				font-weight: bold;
			}
			
			.style span {
				border:1px solid #3882ff;
				padding:2px 7px;
				display:inline-block;
				color: #3882ff;
				margin-right: 3px;
				border-radius: 2px;
				margin: 0 5px 5px 0;
			}
			
			.style-image {
				display: inline-block;
				padding: 30px;
				border: 1px solid black;
				float: left;
			}
			
			.style-number {
				margin-left: 10px;
				margin-top: 20px;
				float: left;
			}
			.table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td {
			    vertical-align: middle;
			}
			
			.table tr td:nth-child(1) {
				min-width: 100px;
				text-align: center;
			}
			/*新增样式*/
			ol{
				list-style: none;
			}
    		.ol_left{
	            width: 100%;
	            height: 30px;
	            line-height: 30px;
	            padding: 0;
	        }
	        .ol_left>li{
	            float: left;
	            margin-right: 5px;
	        }
	        .ol_left li, .ol_left{
	        	margin-bottom: 0;
	        }
	        .left-text{
	        	background: rgb(246, 246, 246);
	        }
	        .dingdan table tr td{
	        	text-align: center;
	        }
	        .dingdan table tr td:nth-child(1) {
	        	text-align: left;
	        }
	        
	        /* 下载和上传按钮样式 */
	        .down{
				width: 90px;
				height: 30px;
				border: 1px solid #99D3F5;
				color: #1E88C7;
				display: inline-block;
				text-align: center;
				border-radius: 2px;
				margin-left: 10px;
			}
			.down-i{
				color: #1E88C7;
			}
			
			.file_fa{
				margin-top: 5px;
			}
			.file {
			    position: relative;
			    display: inline-block;
			    background: #D0EEFF;
			    border: 1px solid #99D3F5;
			    border-radius: 4px;
			    padding: 4px 12px;
			    overflow: hidden;
			    color: #1E88C7;
			    text-decoration: none;
			    text-indent: 0;
			    line-height: 20px;
			}
			.file input {
			    position: absolute;
			    font-size: 100px;
			    right: 0;
			    top: 0;
			    opacity: 0;
			}
			.file:hover {
			    background: #AADFFD;
			    border-color: #78C3F3;
			    color: #004974;
			    text-decoration: none;
			}
			#fileName, #fileName1{
	        	color: #3882ff;
	        }
	        #tijiao{
			    display: inline-block;
			    background: #D0EEFF;
			    border: 1px solid #99D3F5;
			    border-radius: 4px;
			    padding: 4px 12px;
			    overflow: hidden;
			    color: #1E88C7;
			    text-decoration: none;
			    text-indent: 0;
			    line-height: 20px;
	        }
	</style>
    </head>
    <body class="skin-blue">
        <#include "../header.html"/> 
        <div class="wrapper row-offcanvas row-offcanvas-left">
            <#include "../menu.html"/>
            <!-- Right side column. Contains the navbar and content of the page -->
            <aside class="right-side">
            	<section class="content-header">
                    <h1>工厂详情
                    	<small><a href="list">返回</a></small>
                    </h1>
                    <ol class="ol_left">
		                <li>当前位置：</li>
		                <li><a href="list">工厂管理</a></li>
		                <li>> 工厂详情</li>
		            </ol>
		            <hr class="no-margin" />
               </section>
                <!-- Content Header (Page header) -->
                <section class="content">
                    <div class="row">
                    	<div class="col-md-12">
                            <div class="box" style="padding: 20px;">
			                    <div class="pull center">
			                    	<div class="pull-left">
				                    	工厂信息
				                    </div>
				                    <div class="pull-right" style="margin-bottom: 10px;">
			                    		<!-- <span style="margin-right: 5px;">
			                    			最近编辑：2016/10/13&nbsp;17:15
			                    		</span> -->
			                    		<button type="button" class="btn btn-primary btn-sm" onclick="location.href='showModifyPage?factoryId=${factoryDetail.id!}'">编辑</button>&nbsp;&nbsp;&nbsp;
			                    		<button type="button" class="btn btn-default btn-sm" onclick="javascript:deleteFactory('${factoryDetail.id!}')">删除</button>
				                    </div>
			                    </div>
			                    <div class="custormView center">
			                    	<table class="table table-bordered" >
				                    	<tr>
				                    		<td width="10%">名称</td>
				                    		<td width="90%">${factoryDetail.name!}</td> 
				                    	</tr>
				                    	<tr>
				                    		<td>地址</td>
				                    		<td>${factoryAddress!}</td>
				                    	</tr>
				                    	<tr>
				                    		<td>联系人姓名</td>
				                    		<td>
				                    			<#list factoryDetail.factoryContacts as factoryContact>
				                    				${factoryContact.linkman!}&nbsp;&nbsp;&nbsp;
				                    			</#list>
				                    		</td>
				                    	</tr>
				                    	<tr>
				                    		<td>联系电话</td>
				                    		<td>
				                    			<#list factoryDetail.factoryContacts as factoryContact>
				                    				${factoryContact.contact!}&nbsp;&nbsp;&nbsp;
				                    			</#list>
				                    		</td>
				                    	</tr>
				                    	<tr>
				                    		<td>工厂人数</td>
				                    		<td>${factoryDetail.person_amount!}</td>
				                    	</tr>
				                    	<tr>
				                    		<td>梳织类型</td>
				                    		<td class="style">
				                    			<#list factoryDetail.tattingStyle as constant>
				                    			<span>${constant.name!}</span>
				                    			</#list>
				                    		</td>
				                    	</tr>
				                    	<tr>
				                    		<td>针织类型</td>
				                    		<td class="style">
				                    			<#list factoryDetail.wovenStyle as constant>
				                    			<span>${constant.name!}</span>
				                    			</#list>
				                    		</td>
				                    	</tr>
				                    	<tr>
				                    		<td>毛衣类型</td>
				                    		<td class="style">
				                    			<#list factoryDetail.sweaterStyle as constant>
				                    			<span>${constant.name!}</span>
				                    			</#list>
				                    		</td>
				                    	</tr>
				                    	<tr>
				                    		<td>销往目的地</td>
				                    		<td>${factoryDetail.sale_target!}</td>
				                    	</tr>
				                    	<tr>
				                    		<td>合作条件</td>
				                    		<td>${factoryDetail.cooperation_condition!}</td>
				                    	</tr>
				                    	<tr>
				                    		<td>评估报告表</td>
				                    		<td>
				                    			<#if factoryDetail.estimate_report??>
					                    			<span id="fileName1">${factoryDetail.origin_name!}</span>
					                    			<a href="downloadReport?fileName=${factoryDetail.estimate_report!}" class="down"><i class="iconfont down-i"></i>下载评估报告</a>	
		                                            <form id="form" class="file_fa" action="" method="post" enctype="multipart/form-data">
                                    					<a href="javascript:;" class="file">
														    <input id="estimateReport" name="estimateReport" type="file"  multiple  onchange="document.getElementById('fileName').innerHTML=this.value">重新选择评估报告
														</a>
														<span id="fileName"></span>
														<br/>
														<input id="tijiao" type="button" onclick="uploadFile('${factoryDetail.id!}')" value="重新上传" />
                                    				</form>
			                                     <#else>  	
			                    					<form id="form" class="file_fa" action="" method="post" enctype="multipart/form-data">
	                                   					<a href="javascript:;" class="file">
														    <input id="estimateReport" name="estimateReport" type="file"  multiple  onchange="document.getElementById('fileName').innerHTML=this.value">选择评估报告
														</a>
														<span id="fileName"></span>
														<br/>
														<input id="tijiao" type="button" onclick="uploadFile('${factoryDetail.id!}')" value="重新上传" /> 
                                    				</form>
				                    		
				                    			 </#if>
				                    		</td>
				                    	</tr>
				                    </table>
			                    </div>
			                   
			                
                            </div><!-- /.box -->
                       </div><!-- /.col -->
                    </div><!-- /.row -->
                </section>
                
                
                
            </aside><!-- /.right-side -->
        </div><!-- ./wrapper -->


        <!-- jQuery 2.0.2 -->
        <script src="../js/jquery.min.js"></script>
        <!-- Bootstrap -->
        <script src="../js/bootstrap.min.js" type="text/javascript"></script>
        <!-- AdminLTE App -->
        <script src="../js/AdminLTE/app.js" type="text/javascript"></script>
        <!-- AdminLTE for demo purposes -->
       
        <script type="text/javascript">
	      	//删除工厂
			function deleteFactory(id){
				swal({
					  title: "确定要删除?",
					  text: "删除后将无法恢复!",
					  type: "warning",
					  showCancelButton: true,
					  confirmButtonColor: "#DD6B55",
					  confirmButtonText: "确定",
					  cancelButtonText:"取消",
					  closeOnConfirm: false
					},
					function(){
						$.ajax({
	                		url:"../factory/deleteFactory",
	                		data:{"factoryId":id},
	                		type:"post",
	                		success:function(result){
	                			if(result.head.respCode=="0000000"){
	                				if(result.body=="删除成功"){
	                					swal({
		                						title:"工厂删除成功",
		                						type: "success",
		                						showCancelButton: false,
		                						confirmButtonColor: "#DD6B55",
		                						confirmButtonText: "确定",
		                						closeOnConfirm: false
	                						 },function(){
	                							window.location.href = 'list';
	                						});
	                				}else{
	                					swal({
	                						title:result.body,
	                						type:"warning",
	                						showCancelButton: false,
	                						confirmButtonColor: "#DD6B55",
	                						confirmButtonText: "确定",
	                						closeOnConfirm: false
	                					});
	                				}
	                			}else{
	                				swal(result.body, "warning");
	                			}
	                		}
	                	});
					  
					});
			}
        
        	//重新上传工厂报告
        	function uploadFile(id){
        		var formData = new FormData($('#form')[0]);
        		$.ajax({
        			url:"../factory/uploadReport?factoryId="+id,
        			type:"post",
        			data:formData,
        			async: false,  
                    cache: false,  
                    contentType: false,  
                    processData: false,
                    success:function(result){
                    	if(result.head.respCode=="0000000"){
                    		if(result.body=="上传成功"){
                    			success(result.body,function(){
                    				window.location.href="../factory/showDetailPage?factoryId="+id;
                    			});
                    		}else{
                    			alert(result.body);
                    		}
                    	}else{
                    		alert("系统异常，请刷新后重试");
                    	}
                    }
        		});
        	}
        </script>
    </body>
</html>
